 package CurtainDesign;

 import java.util.ArrayList;
 import javax.swing.JOptionPane;

 public class WindowDesc
 {
   protected String m_HingeInstallDesc;
   protected String m_WindowType;
   protected boolean m_DoubleHinge;
   private int m_TotalPanel;
   private int m_HingeNum;
   private int m_DoubleHingeNum;
   private int m_PoleNum;
   private int m_DuikouPoleNum;
   private int m_TPoleNum;
   private float m_Gap;

   public WindowDesc(String hingeInstall, String windowType)
   {
     this.m_HingeInstallDesc = hingeInstall;
     this.m_WindowType = windowType;
   }

   public int GetTotalPanel()
   {
     return this.m_TotalPanel;
   }

   public int GetHingeNum() {
     return this.m_HingeNum;
   }
   public int GetDoubleHingeNum() {
     return this.m_DoubleHingeNum;
   }
   public int GetPoleNum() {
     return this.m_PoleNum;
   }
   public int GetDuikouPoleNum() {
     return this.m_DuikouPoleNum;
   }
   public int GetTPoleNum() {
     return this.m_TPoleNum;
   }
   public float GetGap() {
     return this.m_Gap;
   }

   public boolean GetParaFromHingeInstall()
   {
     String windowType = this.m_WindowType;

     String[] tmp = this.m_HingeInstallDesc.split(":");
     String hingeInstallType;
     if (tmp.length == 1)
       hingeInstallType = tmp[0];
     else
       hingeInstallType = tmp[1];
     String hingeInstall;
     if (hingeInstallType.indexOf(',') != -1)
     {
       String[] tmp2 = hingeInstallType.split(",");
       if (tmp2[1].equalsIgnoreCase("双开"))
       {
         hingeInstall = tmp2[0];
         this.m_DoubleHinge = true;
       }
       else {
         JOptionPane.showMessageDialog(null, "合页安装方式表达错误，请检查", "错误", 0);

         return false;
       }
     }
     else
     {
       if (hingeInstallType.indexOf(65292) != -1)
       {
         String[] tmp2 = hingeInstallType.split("，");
         if (tmp2[1].equalsIgnoreCase("双开"))
         {
           hingeInstall = tmp2[0];
           this.m_DoubleHinge = true;
         }
         else {
           JOptionPane.showMessageDialog(null, "合页安装方式表达错误，请检查", "错误", 0);

           return false;
         }

       }
       else
       {
         hingeInstall = hingeInstallType;
         this.m_DoubleHinge = false;
       }
     }
     this.m_TotalPanel = 0;
     this.m_HingeNum = 0;
     this.m_DoubleHingeNum = 0;
     this.m_PoleNum = 0;
     this.m_DuikouPoleNum = 0;
     this.m_TPoleNum = 0;
     this.m_Gap = 0.0F;
     this.m_TotalPanel = 0;
     ArrayList hingeArray = GetDesFromHingeInstall(hingeInstall);
     if (windowType.equalsIgnoreCase("Normal")) {
       for (int i = 0; i < hingeArray.size(); i++)
       {
         String desc = (String)hingeArray.get(i);
         if (desc.equalsIgnoreCase("T"))
         {
           this.m_TPoleNum += 1;

           String nextDesc = (String)hingeArray.get(i + 1);
           if (nextDesc.substring(1).equalsIgnoreCase("L"))
           {
             this.m_Gap += 1.59F;
             this.m_HingeNum += 1;
           } else {
             this.m_Gap += 3.17F;
           }
         }
         else {
           int num = Integer.parseInt(desc.substring(0, 1));

           this.m_TotalPanel += num;
           if (i == 0) {
             if (desc.substring(1).equalsIgnoreCase("L"))
             {
               this.m_Gap += 1.59F;
               this.m_HingeNum += 1;
             }
             else
             {
               this.m_Gap += 3.17F;
             }

           }

           if (i == hingeArray.size() - 1)
           {
             if (num == 2) {
               if (!this.m_DoubleHinge) {
                 this.m_Gap += 1.59F;
                 this.m_HingeNum += 1;
               } else {
                 this.m_DoubleHingeNum += 1;
               }
             }
             else if (num > 2) {
               JOptionPane.showMessageDialog(null, "系统不支持3扇相连", "错误", 0);

               return false;
             }

             if (desc.substring(1).equalsIgnoreCase("L")) {
               this.m_Gap += 3.17F;

               break;
             }
             this.m_Gap += 1.59F;
             this.m_HingeNum += 1;

             break;
           }

           String nextDesc = (String)hingeArray.get(i + 1);
           if (num == 2) {
             if (!this.m_DoubleHinge) {
               this.m_Gap += 1.59F;
               this.m_HingeNum += 1;
             } else {
               this.m_DoubleHingeNum += 1;
             }
           } else if (num > 2) {
             JOptionPane.showMessageDialog(null, "系统不支持3扇相连", "错误", 0);

             return false;
           }

           if (nextDesc.equalsIgnoreCase("T")) {
             if (desc.substring(1).equalsIgnoreCase("L")) { this.m_Gap += 3.17F;
             } else {
               this.m_Gap += 1.59F;
               this.m_HingeNum += 1;
             }
           } else {
             if (nextDesc.substring(1).equalsIgnoreCase("L"))
             {
               if (desc.substring(1).equalsIgnoreCase("L"))
               {
                 JOptionPane.showMessageDialog(null, "出现1L1L这种情况，字符串错误", "错误", 0);

                 return false;
               }

               JOptionPane.showMessageDialog(null, "出现1R1L这种情况，字符串错误", "错误", 0);

               return false;
             }

             if (desc.substring(1).equalsIgnoreCase("L"))
             {
               this.m_Gap += 3.17F;
               this.m_DuikouPoleNum += 2;
             }
             else
             {
               JOptionPane.showMessageDialog(null, "出现1R1R这种情况，字符串错误", "错误", 0);

               return false;
             }

           }

         }

       }

       this.m_PoleNum = (this.m_TotalPanel * 2 - this.m_DuikouPoleNum);
     }

     return true;
   }

   public static ArrayList GetDesFromHingeInstall(String strInstallType)
   {
     String hingeInstallType = new String(strInstallType);

     ArrayList hingeArray = new ArrayList();
     int oldHingeTypeLength = hingeInstallType.length();
     for (int i = 0; (i < hingeInstallType.length()) &&
       (hingeInstallType.length() >= 2); )
     {
       String strTmp1 = hingeInstallType.substring(0, 2);
       hingeArray.add(strTmp1);
       if (hingeInstallType.length() == 2) {
         break;
       }
       String strTmp2 = hingeInstallType.substring(2, 3);
       if (strTmp2.equalsIgnoreCase("T")) {
         hingeArray.add(strTmp2);
         hingeInstallType = hingeInstallType.substring(3);

         continue;
       }hingeInstallType = hingeInstallType.substring(2);
     }

     return hingeArray;
   }
 }

/* Location:           C:\Users\Administrator\Desktop\奥特百叶窗\Shutter DesignerV3.1\CurtainDesign.jar
 * Qualified Name:     CurtainDesign.WindowDesc
 * JD-Core Version:    0.6.0
 */